home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14213 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  38 lines

  1. Newsgroups: comp.lang.c++,
  2. Path: in2.uu.net!edg1!jsa
  3. From: jsa@edg.com (J. Stephen Adamczyk)
  4. Subject: Re: g++ 2.5.8 -> 2.7.0 Syntax Error
  5. Message-ID: <Dp15zu.It9@edg.com>
  6. Organization: Edison Design Group Inc.
  7. References: <boyseDozKHC.JyA@netcom.com> <4jfhmc$b72@news1.h1.usa.pipeline.com>
  8. Date: Fri, 29 Mar 1996 13:11:53 GMT
  9.  
  10. In article <4jfhmc$b72@news1.h1.usa.pipeline.com> grantp@usa.pipeline.com(Pete Grant) writes:
  11. >On Mar 28, 1996 16:29:35 in article <g++ 2.5.8 -> 2.7.0 Syntax Error>,
  12. >'boyse@netcom.com (William Boyse)' wrote: 
  13. >>Element *Next_Element(Element *ptr_elt) 
  14. >>{ 
  15. >>ptr_elt = new Tri_6(); //  ******* THIS IS THE OFFENDING LINE ******** 
  16. >Omit the parentheses.  When constructing a class without 
  17. >passing any parameters, the parentheses are not appropriate. 
  18.  
  19. The parentheses are not required, but there's nothing wrong with using them.
  20. The real problem in this example is that "Tri_6" is both a class name and
  21. an enumeration constant name:
  22.  
  23. >enum Elt_Type {None, Tri_3, Tri_6, Quad_4, Tet_4};
  24. >class Tri_6 : public Element
  25.  
  26. In the absence of an elaborated type specifier, the compiler is correct in
  27. choosing the enumeration constant, and then giving an error because it's
  28. not a type.  Try
  29.  
  30.     ptr_elt = new class Tri_6;
  31.  
  32. (I don't know if g++ 2.7.0 will accept it, but it is valid C++.)
  33.  
  34. Steve Adamczyk
  35. Edison Design Group
  36.  
  37.